package com.admin.interceptor;

import com.admin.model.Sys_User;
import com.admin.util.Constants;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

public class LoginInterceptor implements Interceptor {

	@Override
	public void intercept(Invocation inv) {
		Controller controller = inv.getController();
		try {
			Sys_User user = controller.getSessionAttr(Constants.LOGIN_USER);
			if(null == user){
				controller.redirect("/");
			}else{
				inv.invoke();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
